import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'
import axios from 'axios'
export const asyncIncre = createAsyncThunk('asyncIncre', async () => {
    const res = await axios.get('/list')
    console.log(res);
    return res.data
})
const countSLice = createSlice({
    name: 'count',
    initialState: {
        name: '张三',
        value: 1,
        todolist: []
    },
    reducers: {
        incre: (state, { payload }) => {
            // console.log(actions, state, '===========');
            state.value += payload
        }
    },
    extraReducers: {
        [asyncIncre.fulfilled]: (state, { payload }) => {
            state.todolist = payload
        }
    }
})
console.dir(countSLice);
export const { incre } = countSLice.actions
export default countSLice.reducer